<script type="text/javascript" src="../media/system/js/jquery-1.9.1.js"></script>
<script type="text/javascript" src="../media/system/js/jQuery.vietvang.validate.js"></script>
	<script type="text/javascript">
		$(document).ready(function(){
			$('#adminForm').validate({
			});
		});
</script>
<?php
     $aut=new bgAuthorize();
    // check  user login
    $group=$aut->getUserGroup();
    $u=JFactory::getUser();
    $u_ocba= $u->USEM_OCBA_CODE;
   
?>
<form action="index.php?option=com_activity" method="post" name="adminForm" id="adminForm" class="adminform" enctype="multipart/form-data">

    <fieldset class="" id="adminformfieldset">
    <legend>基本データ</legend>
      <table class="table-information" style="width: 950px;" border=0>
        <tr>
            <td></td>
            <td class="err">※印は入力必須項目です。</td>
        </tr>
        <tr style="vertical-align: top;line-height: 30px;">
            <td  style="text-align: right;font-size: 1.091em;padding-right:5px;width:27%;vertical-align: top;line-height: 30px;">
                名称<span class='err'>※</span>
            </td>
            <td colspan="3">
                <input data_required="true" vvName="fullname" type="text" name="jform[ACTT_NAME]" value="<?php echo $this->row['ACTT_NAME']; ?>" class="inputbox large" style="width:92%" size="30" />
                <span name="msg_error" ></span>
            </td>

        </tr>
        <tr>
            <td style="text-align: right;font-size: 1.091em;padding-right:5px;width:20%;">
                オススメ度
            </td>
            <td colspan="4">
                <select name="jform[ACTT_RECOMMENDED_DEGREE]" class="inputbox medium">
                <?php 
                        foreach(bgData::getRecommended() as $key=>$item){
                            ?>
                            <option value="<?php echo $key; ?>"<?php if ($this->row['ACTT_RECOMMENDED_DEGREE'] == $key) { echo ' selected="selected"';} ?>>
                            <?php echo $item; ?></option>
                            <?php 
                        }
                     ?>
                
                </select>
            </td>
        </tr>
        <tr style="vertical-align: top;line-height: 30px;">
            <td style="text-align: right;font-size: 1.091em;padding-right:5px;vertical-align: top;line-height: 30px;">
                センター・クラブコード<span class="err">※</span>
            </td>
            <td style="width: 200px;" >
            <?php
                if($group!=11) {
             ?>
                 <input style="float: left" type="text" vvName="number" name="jform[ACTT_OCBA_CODE]" value="<?php echo $this->row['ACTT_OCBA_CODE']; ?>" id="jformACTT_OCBA_CODE" class="inputbox medium" size="30" />
                 <a style="float: left; line-height: 3" href="" id="link_ocba_code" style="line-height: 30px;" >検索</a>
                 <span name="msg_error"></span>
                 <?php }
                 else 
                    {
                    ?>
                 <input type="text" readonly="true" vvName="number" name="jform[ACTT_OCBA_CODE]" value="<?php echo $u_ocba; ?>" id="jformACTT_OCBA_CODE" class="inputbox medium" size="30" />
                        <?php
                        
                    }
                  ?>
                 
            </td>
            <td colspan="3"></td>  
        </tr>
        
         <tr style="vertical-align: top;line-height: 30px;">
            <td style="text-align: right;font-size: 1.091em;padding-right:5px;">
               期間
            </td>
            <td class="td_left" style="width:22%">
                <?php if($this->row['ACTT_PERIOD_START'] != 0){ $dt = date('Y-m-d',strtotime($this->row['ACTT_PERIOD_START']));}else{ $dt=null;} echo JHtml::calendar($dt, 'jform[ACTT_PERIOD_START]', 'jformACTT_PERIOD_START');?>
                <span name="msg_error"></span>
            </td>
            <td style="width: 4%;text-align:left;vertical-align: top;line-height: 30px;">～</td>
            <td style="width: 20%;">
                <?php if($this->row['ACTT_PERIOD_FINISH'] != 0){ $dt = date('Y-m-d',strtotime($this->row['ACTT_PERIOD_FINISH']));}else{ $dt=null;} echo JHtml::calendar($dt, 'jform[ACTT_PERIOD_FINISH]', 'jformACTT_PERIOD_FINISH');?>
                <span name="msg_error"></span>
            </td>
            <td></td>
        </tr>
        <tr>
            <td style="text-align: right;font-size: 1.091em;padding-right:5px;">
                募集ステータス
            </td>
            <td colspan="4">
                <select name="jform[ACTT_RECR]" class="inputbox medium">
                    <option value="1">募集開始前</option>
                    <option value="2">募集中</option>
                    <option value="3">募集終了</option>                        
                </select>
            </td>
         </tr>
         <tr>
            <td style="text-align: right;font-size: 1.091em;padding-right:5px;">
                会場
            </td>
            <td colspan="4">
                <input type="text" name="jform[ACTT_VENUE]" value="<?php echo $this->row['ACTT_VENUE']; ?>" class="inputbox medium" size="30" />
            </td>
         </tr>
         <tr>
            <td style="text-align: right;font-size: 1.091em;padding-right:5px;">
                主催
            </td>
            <td colspan="4">
                 <input type="text" name="jform[ACTT_TOCHUC]" value="<?php echo $this->row['ACTT_TOCHUC']; ?>" class="inputbox medium" size="30"/>
            </td>
         </tr>
         <tr>
            <td style="text-align: right;font-size: 1.091em;padding-right:5px;">
                後援
            </td>
            <td colspan="4">
                <input type="text" name="jform[ACTT_TAITRO]" value="<?php echo $this->row['ACTT_TAITRO']; ?>" class="inputbox medium" size="30" />
            </td>
         </tr>
         <tr>
            <td style="text-align: right;font-size: 1.091em;padding-right:5px;">
                協力
            </td>
            <td colspan="4">
                 <input type="text" name="jform[ACTT_COOPERATION]" value="<?php echo $this->row['ACTT_COOPERATION']; ?>" class="inputbox medium" size="30"/>
            </td>
         </tr>
         <tr>
            <td style="text-align: right;font-size: 1.091em;padding-right:5px;">
                問合せ先
            </td>
            <td colspan="4">
                 <input type="text" name="jform[ACTT_CONTACT]" value="<?php echo $this->row['ACTT_CONTACT']; ?>" class="inputbox medium" />
            </td>
         </tr>
         <tr>
            <td style="text-align: right;font-size: 1.091em;padding-right:5px;">
                問合わせ先 担当者名
            </td>
            <td colspan="4">
                 <input type="text" name="jform[ACTT_PERSON]" value="<?php echo $this->row['ACTT_PERSON']; ?>" class="inputbox medium" />
            </td>
         </tr>
         <tr style="vertical-align: top;line-height: 30px;">
            <td style="text-align: right;font-size: 1.091em;padding-right:5px;">
                問合わせ先 電話番号
            </td>
            <td>
                 <input type="text" vvName="phone" name="jform[ACTT_TEL]" value="<?php echo $this->row['ACTT_TEL']; ?>" class="inputbox medium" />
                <span name="msg_error"></span>
            </td>
         </tr>
      </table>
    </fieldset>
    <fieldset class="" id="adminformfieldset">
        <legend>基本概要</legend>
      <table class="table-information" border=0>
         <tr>
            <td style="text-align: right;font-size: 1.091em;padding-right:5px;width:20%;vertical-align:middle">
                趣旨
            </td>
            <td colspan="4">
                <textarea name="jform[ACTT_EFFECT]" cols="62" rows="4" style="width: 80%;"><?php echo $this->row['ACTT_EFFECT']; ?></textarea>
            </td>
         </tr>
         <tr>
            <td style="text-align: right;font-size: 1.091em;padding-right:5px;">
              対象
            </td>
            <td style="width: 150px;">
                 <input type="text" value="<?php echo $this->row['ACTT_TARGET']; ?>" name="jform[ACTT_TARGET]" class="inputbox medium" size="30" />
            </td>
            <td style="text-align: right;font-size: 1.091em;padding-right:5px;width: 100px;line-height: 30px;" >
                性別
            </td>
            <td class="text-align-left" style="width: 300px;">
                <select name="jform[ACTT_SEX]" class="inputbox medium">
                    <option value="1" <?php if($this->row['ACTT_SEX'] == 1){ echo 'selected="selected"'; } ?> >男性</option>
                    <option value="2" <?php if($this->row['ACTT_SEX'] == 2){ echo 'selected="selected"'; } ?> >女性</option>
                    <option value="0" <?php if($this->row['ACTT_SEX'] == 0){ echo 'selected="selected"'; } ?> >全て</option>                     
                </select>
            </td>
         </tr>
          <tr style="vertical-align: top;line-height: 30px;">
            <td style="text-align: right;font-size: 1.091em;padding-right:5px;">
                参加人数
            </td>
            <td style="width: 200px;">
                <input type="text" vvName="digits_f" name="jform[ACTT_NUMBER_OF_PARTICIPANTS]" value="<?php echo $this->row['ACTT_NUMBER_OF_PARTICIPANTS']; ?>" class="inputbox medium" size="30" /><span style="font-size:1.091em;line-height: 30px;">人</span>
                <span name="msg_error"></span>   
            </td>
         </tr>
          <tr style="vertical-align: top;line-height: 30px;">
            <td style="text-align: right;font-size: 1.091em;padding-right:5px;">
               参加費
            </td>
            <td>
                <input type="text" vvName="digits_f" name="jform[ACTT_ENTRY_FEE]" value="<?php echo $this->row['ACTT_ENTRY_FEE']; ?>" class="inputbox medium" size="30" /><span style="font-size:1.091em ;line-height: 30px;">円</span>
                <span name="msg_error"></span> 
            </td>
         </tr>
         <tr style="vertical-align: top;line-height: 30px;">
            <td style="text-align: right;font-size: 1.091em;padding-right:5px;">
                総事業費
            </td>
            <td>
                <input type="text" vvName="digits_f" name="jform[ACTT_TOTAL_PROJECT_COST]" value="<?php echo $this->row['ACTT_TOTAL_PROJECT_COST']; ?>" class="inputbox medium" size="30" /><span style="font-size:1.091em ;line-height: 30px;">円</span>
                <span name="msg_error"></span>    
            </td>
         </tr>
          <tr>
            <td style="text-align: right;font-size: 1.091em;padding-right:5px;vertical-align:middle">
                事業内容
            </td>
            <td colspan="4">
                
                 <textarea rows="4" name="jform[ACTT_BUSINESS]" cols="62" rows="4" style="width: 80%;" ><?php echo $this->row['ACTT_BUSINESS']; ?></textarea>
            </td>
         </tr>
          <tr>
            <td style="text-align: right;font-size: 1.091em;padding-right:5px;vertical-align:middle">
                備考
            </td>
            <td colspan="4">
                <textarea rows="4" name="jform[ACTT_REMARKS]" cols="62" rows="4" style="width: 80%;" ><?php echo $this->row['ACTT_REMARKS']; ?></textarea>
            </td>
         </tr>
        </table>
    </fieldset>
    <fieldset class="" id="adminformfieldset">
        <legend>ジャンル</legend>

      <table id="list-check" class="table-information" style="width: 100%;" border=0>
        <?php
            $count_mfac = count($this->list_mfac);
            $count_all = $count_mfac;
            $i = 0;
            while($count_mfac > 0){
        ?>
        <tr >

             <td class="td_small" style="text-align: right;font-size: 1.091em;padding-right:5px;"><?php if($count_mfac == $count_all){ ?>施設<?php } ?></td>           
            <?php
                
                if($this->list_mfac != null){
                    
                    if(isset($this->list_mfac_check)){ $list_mfac_check = explode(",",$this->list_mfac_check); }    
                     for($item1=$i;$item1 < count($this->list_mfac); $item1++){
                        $i++;
                        $count_mfac--;
                        
            ?>
            <td style="width: 20%;"><input style="float: left;text-align:left;" type="checkbox" name="jform[MFAC<?php echo $this->list_mfac[$item1]->MFAC_CODE; ?>]" id="MFAC<?php echo $this->list_mfac[$item1]->MFAC_CODE; ?>" value="<?php echo $this->list_mfac[$item1]->MFAC_CODE; ?>"  <?php if(isset($list_mfac_check)){ foreach($list_mfac_check as $val){ if($this->list_mfac[$item1]->MFAC_CODE == $val){ echo 'checked="checked"'; }} } ?> /><label style="line-height: 30px !important;margin-left: 20px;float:left; margin-top:-28px;" for="MFAC<?php echo $this->list_mfac[$item1]->MFAC_CODE; ?>" style="line-height: 4px !important;margin-left: 5px;" ><?php echo $this->list_mfac[$item1]->MFAC_NAME; ?></label></td>
              <?php
                         if($i==4){
                            break;
                         }
                    }
                }
            ?>
        </tr>
        <?php } ?>
        
        <?php
            $count_mobj = count($this->list_mobj);
            $count_all = $count_mobj;
            $i = 0;
            while($count_mobj > 0){
        ?>
        <tr>
            <td class="td_small" style="text-align: right;font-size: 1.091em;padding-right:5px;"><?php if($count_mobj == $count_all){ ?>対象<?php } ?></td>
            <?php
                
                if($this->list_mobj != null){
                    
                    if(isset($this->list_mobj_check)){ $list_mobj_check = explode(",",$this->list_mobj_check); }
                    
                    for($item1=$i;$item1 < count($this->list_mobj); $item1++){
                        $i++;
                        $count_mobj--;
            ?>
            <td style="width: 20%;"><input style="float: left;text-align:left;" type="checkbox" name="jform[MOBJ<?php echo $this->list_mobj[$item1]->MOBJ_CODE; ?>]" id="MOBJ<?php echo $this->list_mobj[$item1]->MOBJ_CODE; ?>" value="<?php echo $this->list_mobj[$item1]->MOBJ_CODE; ?>"  <?php if(isset($list_mobj_check)){ foreach($list_mobj_check as $val){ if($this->list_mobj[$item1]->MOBJ_CODE == $val){ echo 'checked="checked"'; }} } ?> /><label style="line-height: 30px !important;margin-left: 20px;float:left; margin-top:-28px;" for="MOBJ<?php echo $this->list_mobj[$item1]->MOBJ_CODE; ?>" style="line-height: 30px !important;margin-left: 5px; margin-top: -28px;" ><?php echo $this->list_mobj[$item1]->MOBJ_NAME; ?></label></td>
            
            <?php
                         if($i==4){
                            break;
                         }
                    }
                }
            ?>
            
            
        </tr>
        <?php } ?>
        
        
        <?php
            $count_mcon = count($this->list_mcon);
            $count_all = $count_mcon;
            $i = 0;
            while($count_mcon > 0){
        ?>
        <tr>
            <td class="td_small" style="text-align: right;font-size: 1.091em;padding-right:5px;"><?php if($count_mcon == $count_all){ ?>内容<?php } ?></td>
            <?php
                
                if($this->list_mcon != null){
                    
                    if(isset($this->list_mcon_check)){ $list_mcon_check = explode(",",$this->list_mcon_check); }
                    
                    for($item2=$i;$item2 < count($this->list_mcon); $item2++){
                        $i++;
                        $count_mcon--;
            ?>
            <td style="width: 20%;"><input style="float: left;text-align:left;" type="checkbox" name="jform[MCON<?php echo $this->list_mcon[$item2]->MCON_CODE; ?>]" id="MCON<?php echo $this->list_mcon[$item2]->MCON_CODE; ?>" value="<?php echo $this->list_mcon[$item2]->MCON_CODE; ?>"  <?php if(isset($list_mcon_check)){ foreach($list_mcon_check as $val){ if($this->list_mcon[$item2]->MCON_CODE == $val){ echo 'checked="checked"'; }} } ?> /><label style="line-height: 30px !important;margin-left: 20px;float:left; margin-top:-28px;" for="MCON<?php echo $this->list_mcon[$item2]->MCON_CODE; ?>" style="line-height: 4px !important;margin-left: 5px;" ><?php echo $this->list_mcon[$item2]->MCON_NAME; ?></label></td>
            
            <?php
                         if($i==4){
                            break;
                         }
                    }
                }
            ?>
            
            
        </tr>
        <?php } ?>
        
      </table>
     </fieldset> 
      
    <fieldset class="" id="adminformfieldset">
    <legend>画面データ</legend>
     <table class="table-information" border=0>
        <tr>
            <td></td>
            <td colspan="2" class="waiting">(推奨される画像の縦横比は「3:4」です。)</td>
        </tr>
        <tr>
            <td style="width: 22%;vertical-align: top;" class="text_right">画面ファイル1</td>
            <td style="width: 10%";>
              <!--<input type="file" name="jformACTT_IMAGE_1" value="" />            -->
              <?php HelperBG::getLibUploadify(); ?>
              <?php HelperBG::getUpload('jformACTT_IMAGE_1', $this->row['ACTT_IMAGE_1'], 'uploads/images/com_activity'); ?>
            </td>
            <td style="width: 60%";>
                <input type="text" name="jform[ACTT_DECR_IMG_1]" value="" class="inputbox big" />
            </td>
            
        </tr>
        <tr>
            <td></td>
            <td colspan="2" class="waiting">(推奨される画像の縦横比は「3:4」です。)</td>
        </tr>
        <tr>
            <td class="text_right" style="vertical-align: top;">画面ファイル2</td>
            <td>
              <!-- <input type="file" name="jformACTT_IMAGE_2" value="" /> -->
                <?php HelperBG::getUpload('jformACTT_IMAGE_2', $this->row['ACTT_IMAGE_2'], 'uploads/images/com_activity'); ?>
            </td>
            <td>
                <input type="text" name="jform[ACTT_DECR_IMG_2]" value="" class="inputbox medium big" />
            </td>
        </tr>
        <tr>
            <td></td>
            <td colspan="2" class="waiting">(推奨される画像の縦横比は「3:4」です。)</td>
        </tr>
        <tr>
            <td class="text_right" style="vertical-align: top;">画面ファイル3</td>
            <td>
              <!-- <input type="file" name="jformACTT_IMAGE_3" value="" /> -->
              <?php HelperBG::getUpload('jformACTT_IMAGE_3', $this->row['ACTT_IMAGE_3'], 'uploads/images/com_activity'); ?>
            </td>
            <td>
                <input type="text" name="jform[ACTT_DECR_IMG_3]" value="" class="inputbox medium big" />
            </td>
            
        </tr>
        <tr>
            <td></td>
            <td colspan="2" class="waiting">(推奨される画像の縦横比は「3:4」です。)</td>
        </tr>
        <tr>
            <td class="text_right" style="vertical-align: top;">画面ファイル4</td>
            <td>
              <!--  <input type="file" name="jformACTT_IMAGE_4" value="" />-->
              <?php HelperBG::getUpload('jformACTT_IMAGE_4', $this->row['ACTT_IMAGE_4'], 'uploads/images/com_activity'); ?>
            </td>
            <td>
                <input type="text" name="jform[ACTT_DECR_IMG_4]" value="" class="inputbox medium big" />
            </td>
            
        </tr>
        <tr>
            <td></td>
            <td colspan="2" class="waiting">(推奨される画像の縦横比は「3:4」です。)</td>
        </tr>
        <tr>
            <td class="text_right" style="vertical-align: top;">画面ファイル5</td>
            <td>
              <!-- <input type="file" name="jformACTT_IMAGE_5" value="" /> -->
              <?php HelperBG::getUpload('jformACTT_IMAGE_5', $this->row['ACTT_IMAGE_5'], 'uploads/images/com_activity'); ?>
            </td>
            <td>
                <input type="text" name="jform[ACTT_DECR_IMG_5]" value="" class="inputbox medium big" />
            </td>
            
        </tr>
        
       </table>
    </fieldset>
       
       
    <fieldset class="" id="adminformfieldset">
        <legend>添付ファイル</legend>
        <table class="table-information">
        <tr>
            <td style="width: 22%;" class="text_right">添付ファイル1</td>
            <td style="width: 10%;">
              <!-- <input type="file" name="jformACTT_ATTACHMENT_1" value="" /> -->
               <?php HelperBG::getUpload('jformACTT_ATTACHMENT_1', $this->row['ACTT_ATTACHMENT_1'], 'uploads/files/com_activity'); ?>
            </td>
            <td style="width: 60%;">
                <input type="text" name="jform[ACTT_DECR_ATT_1]" value="" class="inputbox medium big" />
            </td>
            
        </tr>
        <tr>
            <td class="text_right">添付ファイル2</td>
            <td><!-- <input type="file" name="jformACTT_ATTACHMENT_2" value="" /> -->
              <?php HelperBG::getUpload('jformACTT_ATTACHMENT_2', $this->row['ACTT_ATTACHMENT_2'], 'uploads/files/com_activity'); ?>
            </td>
            <td>
                <input type="text" name="jform[ACTT_DECR_ATT_2]" value="" class="inputbox medium big" />
            </td>
            
        </tr>
        <tr>
            <td class="text_right">添付ファイル3</td>
            <td><!-- <input type="file" name="jformACTT_ATTACHMENT_3" value="" /> -->
                <?php HelperBG::getUpload('jformACTT_ATTACHMENT_3', $this->row['ACTT_ATTACHMENT_3'], 'uploads/files/com_activity'); ?>
            </td>
            <td>
                <input type="text" name="jform[ACTT_DECR_ATT_3]" value="" class="inputbox medium big" />
            </td>
            
        </tr>
        <tr>
            <td class="text_right">添付ファイル4</td>
            <td><!-- <input type="file" name="jformACTT_ATTACHMENT_4" value="" /> -->
                <?php HelperBG::getUpload('jformACTT_ATTACHMENT_4', $this->row['ACTT_ATTACHMENT_4'], 'uploads/files/com_activity'); ?>
            </td>
            <td>
                <input type="text" name="jform[ACTT_DECR_ATT_4]" value="" class="inputbox medium big" />
            </td>
            
        </tr>
        <tr>
            <td class="text_right">添付ファイル5</td>
            <td><!-- <input type="file" name="jformACTT_ATTACHMENT_5" value="" /> -->
                <?php HelperBG::getUpload('jformACTT_ATTACHMENT_5', $this->row['ACTT_ATTACHMENT_5'], 'uploads/files/com_activity'); ?>
            </td>
            <td>
                <input type="text" name="jform[ACTT_DECR_ATT_5]" value="" class="inputbox medium big" />
            </td>
            
        </tr>
        <tr>
            <td class="text_right">添付ファイル6</td>
            <td><!-- <input type="file" name="jformACTT_ATTACHMENT_6" value="" /> -->
                <?php HelperBG::getUpload('jformACTT_ATTACHMENT_6', $this->row['ACTT_ATTACHMENT_6'], 'uploads/files/com_activity'); ?>
            </td>
            <td>
                <input type="text" name="jform[ACTT_DECR_ATT_6]" value="" class="inputbox medium big" />
            </td>
            
        </tr>
        
       </table>
     </fieldset>
	   <input type="hidden" name="task" value="" />
       <input type="hidden" name="action" value="new" />
	
</form>

<script>

    /*show a dialog box: center search */
    jq('#link_ocba_code').bind('click', function(e){
        e.preventDefault();
            zb = new jq.Zebra_Dialog('', {
                source:  {'ajax': 'index.php?option=com_activity&views=bg&task=popup_ocba&tmpl=component'},
                height: 800,
                width: 550,
                title:  'センター・クラブ検索',
                type:  '',
                buttons:  [
                    {caption: '閉じる', callback: function() { }}
                        
                ]
            });
    });
    /*select center id */
    jq(".link_ocba_code").live("click",function(){
        //var id = jq(this).html();
        var id = jq("#ocba_code_temp").val();
        jq("#jformACTT_OCBA_CODE").val(id);
        zb.close();
    });
            
    window.addEvent('domready', function() {Calendar.setup({
        	// Id of the input field
        	inputField: "jformACTT_PERIOD_START",
        	// Format of the input field
        	ifFormat: "%Y/%m/%d",
        	// Trigger for the calendar (button ID)
        	button: "jformACTT_PERIOD_START",
        	// Alignment (defaults to "Bl")
        	align: "Bl",
        	singleClick: true,
        	firstDay: 0
    	});
    });
    
    window.addEvent('domready', function() {Calendar.setup({
        	// Id of the input field
        	inputField: "jformACTT_PERIOD_FINISH",
        	// Format of the input field
        	ifFormat: "%Y/%m/%d",
        	// Trigger for the calendar (button ID)
        	button: "jformACTT_PERIOD_FINISH",
        	// Alignment (defaults to "Bl")
        	align: "Bl",
        	singleClick: true,
        	firstDay: 0
    	});
    });
</script>